/**
 * 
 */
package com.dsbridge.enrollment.client;

import java.util.Date;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;

import com.dsbridge.enrollment.entities.Student;

/**
 * @author rithvik
 *
 */
public class JPAClient {
	public static void main(String[] args) {
		EntityManagerFactory emf=Persistence.createEntityManagerFactory("enrollUnit");
		EntityManager entityManager=emf.createEntityManager();
		//Transaction
		Student student=new Student();
		student.setDateOfRegistration(new Date());
		student.setFirstName("Aditya");
		student.setLastName("Bobba");
		student.setLoginName("adityab");
		student.setMiddleName("K");
		student.setPassword("Aditya");
		EntityTransaction et=entityManager.getTransaction();
		et.begin();
		entityManager.persist(student);
		System.out.println(student.getStudentId());
		Student st=entityManager.find(Student.class, 2);
		entityManager.remove(st);
		et.commit();
		
		
		//System.out.println(st.getLoginName());
		//
		
	}

}
